package com.battle.service.repository.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.battle.pojo.entity.WarCaseStudy;
import com.battle.pojo.enums.StudyStatusEnum;
import com.battle.pojo.vo.caseBaseInfo.CaseCakeDetailsVo;
import com.battle.pojo.vo.caseBaseInfo.CaseCakeVo;
import com.battle.service.mapper.WarCaseStudyMapper;
import com.battle.service.repository.in.WarCaseStudyRepository;
import nirvana.core.repository.Repository;

import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
    import com.battle.pojo.dto.warCaseStudy.*;
    import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

/**
* 【描 述】：
* 【环 境】：J2SE
* 【详 细】：
*
*/
@Service
public class WarCaseStudyRepositoryImpl extends Repository< WarCaseStudyMapper , WarCaseStudy> implements WarCaseStudyRepository {

private final WarCaseStudyMapper mapper;

public WarCaseStudyRepositoryImpl(WarCaseStudyMapper mapper) {
this.mapper = mapper;
}

    /**
    * 搜索战例研讨
    * @param dto
    * @return
    */
    @Override
    public Page< WarCaseStudy > selectWarCaseStudy(SelectWarCaseStudyDto dto){

    return mapper.selectWarCaseStudy(dto);
    }

@Override
public  Map<Long, WarCaseStudy> getMap(List<Long> ids){
    Map<Long, WarCaseStudy> map = new HashMap<>();

    if (CollectionUtil.isNotEmpty(ids)) {
        List<WarCaseStudy> list =listByIds(ids);
        if (CollectionUtil.isNotEmpty(list)) {
        map = list.stream().collect(Collectors.toMap(WarCaseStudy::getId, pojo -> pojo));
         }
        }
        return map;
    }

    @Override
    public List<CaseCakeDetailsVo> getCaseCakeVoList(LocalDate startTime, LocalDate endTime) {
        return mapper.getCaseCakeVoList(startTime, endTime);
    }

    @Override
    public List<CaseCakeDetailsVo> getStudyCakeVoList(LocalDate startTime, LocalDate endTime, StudyStatusEnum status, Boolean isSpecialist) {
        return mapper.getStudyCakeVoList(startTime, endTime, status, isSpecialist);
    }

    @Override
    public List<CaseCakeDetailsVo> getCaseTimeVoList(LocalDate startTime, LocalDate endTime) {
        return mapper.getCaseTimeVoList(startTime, endTime);
    }

    @Override
    public List<CaseCakeDetailsVo> getStudyTimeVoList(LocalDate startTime, LocalDate endTime) {
        return mapper.getStudyTimeVoList(startTime, endTime);
    }
}